package Dungeoneering.ActionHandlers;

import org.powerbot.game.api.wrappers.Entity;
import org.powerbot.game.api.wrappers.Tile;
import org.powerbot.game.api.wrappers.interactive.NPC;
import org.powerbot.game.api.wrappers.node.GroundItem;
import org.powerbot.game.api.wrappers.node.Item;
import org.powerbot.game.api.wrappers.node.SceneObject;

import Dungeoneering.Utils.CameraUtils.CameraDirection;

/**
 * This is the ActionHandler. Basicly ANY input (except Keyboard text keypresses) goes through here. It will make use of the CameraHandler and MouseHandler to flawlessly do actions ingame
 * @author Nicolaas
 *
 */
public class ActionHandler {
	
	private static final MouseHandler mouse = MouseHandler.getInstance();
	private static final CameraHandler camera = CameraHandler.getInstance();
	
	public static void pickupGroundItem(GroundItem item) {
		if (item != null)
			mouse.clickFirstOption(item);
	}
	
	public static void interactNpc(NPC n, String action) {
		if (n != null) {
			if (n.getActions()[0].equalsIgnoreCase(action))
				mouse.clickFirstOption(n);
			else
				// TODO mouse.clickOtherOption
				return;
		}
	}
	
	public static void interactLocation(SceneObject l, String action) {
		if (l != null) {
			if (l.getDefinition().getActions()[0].equalsIgnoreCase(action))
				mouse.clickFirstOption(l);
			else
				// TODO mouse.clickOtherOption
				return;
		}
	}
	
	public static void walkTo(Entity e) {
		if (e != null) {
			if (!e.isOnScreen()) {
				walkToMiniMap(e);
			} else {
				// TODO : implement
			}
		}
	}
	
	public static void walkToMiniMap(Entity e) {
		if (e != null) {
			// TODO : implement herp derp
		}
	}
	
	public static void turnCamera(CameraDirection direction, int pitch) {
		camera.setCamera(direction.ordinal() * 45, pitch);
	}
	
	public static void turnCamera(CameraDirection direction) {
		camera.setAngle(direction.ordinal() * 45);
	}
	
	public static void lookAtLocation(SceneObject l) {
		//TODO self explanatory
	}
	
	public static void walkNearLocation(SceneObject l) {
		//TODO stop 1 tile before you get to location
	}
	
	public static void walkNearTile(Tile t) {
		//TODO stop 1 tile before you get to tile
	}
	
	public static void walkToTile(Tile t) {
		//TODO stand on the tile
	}
	
	public static void scanWhileRunning() {
		//TODO Not sure on this one, while running to something you could scan
		// with camera to look for stuff off screen - not important atm
	}
	
	/*
	public static void changeAttackStyle(Location l) {
		//TODO for the future
	}
	
	public static void changePrayerStyle(Location l) {
		//TODO for the future
	}*/
	
	
	public static void useItemWithLocation(Item i, SceneObject l) {
		
	}
	
	public static void useItemWithNpc(Item i, NPC n) {
		
	}
	
	public static void useItemWithItem(Item first, Item second) {
		
	}
	
	public static void interactInventoryItem(Item i, String action) {
		
	}
	
	/**
	 * spamclicks on an inventory item and spams the key, to hopefully succeed in making whatever it is ur making
	 * @param i the item in your inventory to spamclick on
	 * @param key the Key press to spam
	 * @param timeout the amount of milliseconds this may take
	 * @return true if succeeded
	 */
	public static boolean spamClickAndSendKey(Item i, char key, long timeout) {
		return false;
	}
}
